﻿using System.Linq;

namespace CivilRegistry.ControlledModel.Repository
{
    /// <summary>
    /// The <see cref="User"/> repository.
    /// </summary>
    public class UserRepository : AbstractRepository<User>
    {
        /// <summary>
        /// Finds the <see cref="User"/> by username and password.
        /// </summary>
        /// <param name="userName">The user name.</param>
        /// <param name="password">The password.</param>
        /// <returns>Found <see cref="User"/> object, null if not found.</returns>
        public User FindBy(string userName, string password)
        {
            return this.FindAll(user => user.UserName == userName && user.Password == password).FirstOrDefault();
        }

    }
}